//
//  CTCConsultQuestionCell.m
//  CTC
//
//  Created by 李小龙 on 2017/3/29.
//  Copyright © 2017年 jieshuibao. All rights reserved.
//

#import "CTCO2OConsultQuestionCell.h"
#import "HZPhotoGroup.h"


@interface CTCO2OConsultQuestionCell ()
@property (weak, nonatomic) IBOutlet UIImageView *headImageView;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *contentLabel;
@property (weak, nonatomic) IBOutlet UILabel *dateLable;
@property (weak, nonatomic) IBOutlet HZPhotoGroup *photoGroup;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *photoGroupHeight;


@end

@implementation CTCO2OConsultQuestionCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    
}

- (void)setQuestionModel:(CTCQuestionModel *)questionModel
{
    _questionModel = questionModel;
     [SDWebImageTool imageView:self.headImageView imageName:questionModel.headImg placeHolder:@"default-head" showProgress:NO];
    _nameLabel.text = questionModel.name;
    self.contentLabel.text = questionModel.content;
    self.dateLable.text = [NSDate stringFromTimestamp:questionModel.date];
    [self imageShow];
    
    
}



- (void)setShowImage:(CTCConsultQuestionCellShowImageType)showImage
{
    _showImage = showImage;
    [self imageShow];
}

- (void)imageShow
{
    if (!self.questionModel || !self.questionModel.imgs || !self.questionModel.imgs.length) {
        _photoGroup.photoItemArray = @[];
        [_photoGroup setHeight:0];
        _photoGroupHeight.constant = 0;
        return;
    }
    
    NSMutableArray *images = [@[] mutableCopy];
     
    NSArray *arr = [_questionModel.imgs componentsSeparatedByString:@","];

    [arr enumerateObjectsUsingBlock:^(NSString *obj, NSUInteger idx, BOOL * _Nonnull stop) {
        [images addObject:[NSString stringWithFormat:@"%@/%@/%@", kMainBaseUrl, kShowImage, obj]];
    }];
    
    _photoGroup.photoItemArray = images;
    _photoGroupHeight.constant = _photoGroup.height;
    
}

- (IBAction)replyBtnClick {
    if (self.replyBtnClickBlock) {
        self.replyBtnClickBlock();
    }
}



@end
